#include <stdio.h>
#include <fcntl.h>
#include <event.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>

void write_cb(int fd, short event, void *arg) {
    char buf[1024] = {0};
    static int num = 0;
    sprintf(buf, "hello world %d", num++);
    write(fd, buf, sizeof buf);
}

int main() {
    int fd = open("myfifo", O_WRONLY);
    
    struct event_base* evbase = event_base_new();
    struct event* ev = event_new(evbase, fd, EV_WRITE | EV_PERSIST, write_cb, NULL);
    event_add(ev, NULL);
    event_base_dispatch(evbase);
    event_free(ev);
    event_base_free(evbase);
    return 0;
}